
function nodamage(attacker, bodypart)
	if not attacker then return end
	if getElementType(attacker) == 'vehicle' then
		cancelEvent()
	end
end
addEventHandler("onClientPlayerDamage", getLocalPlayer(),nodamage)

local REFRESH_INTERVAL=1000

addEvent("core:blipyaut", true)
addEventHandler("core:blipyaut", root, function(plr)
if plr ~= localPlayer then return end
local uid=getElementData(plr,"player:data").uid
for id, veh in ipairs( getElementsByType ( "vehicle" ) ) do
local data = getElementData(veh, "vehicle:data")
if uid == data.ownedPlayer then
createBlipAttachedTo(veh,0,2,255,0,0,255,1,99999)
end
end
end)
function destroyBlipsAttachedTo(elemente)
	local attached = getAttachedElements ( elemente )
	if ( attached ) then
		for k,element in ipairs(attached) do
			if getElementType ( element ) == "blip" then
				destroyElement ( element )
			end
		end
	end
end
local blip = {}
function veh_blips()
	if getElementData(localPlayer,"player:data") and getElementData(localPlayer,"player:data").logged then
    for i,v in pairs(getElementsByType("vehicle")) do
		if blip[v] then return end
		local data = getElementData(v, "vehicle:data")
		if data then
			if getElementHealth(v) < 300 then setElementHealth(v,305) end
            if data.ownedPlayer == getElementData(localPlayer,"player:data").uid then
				blip[v] = createBlipAttachedTo(v,0,2,255,0,0,255,1,99999)
            end
			if data.ownedPlayer == getElementData(localPlayer,"player:data").gang and (data.ownedPlayer ~= getElementData(localPlayer,"player:data").uid) then
				blip[v] = createBlipAttachedTo(v,0,2,51,0,150,255,1,99999)
            end
			local rent = data.rent
			if rent and (type(rent) == "table") then
				for i,s in pairs(rent) do
					if tonumber(s) == getElementData(localPlayer,"player:data").uid then
						blip[v] = createBlipAttachedTo(v,0,2.2,0,0,255,255,1,99999)
					end
				end
			end
        end
    end
end
end
setTimer(veh_blips,1000,0)
setTimer(veh_blips, REFRESH_INTERVAL, 1000)
addEventHandler("onClientElementDestroy", root, function ()
	if getElementType(source) == "vehicle" then
	destroyBlipsAttachedTo(source)
	end
end)
addEventHandler ( "onClientElementDataChange", root,
function ( dataName )
	if getElementType ( source ) == "vehicle" and dataName == "ownedPlayer" then
		destroyBlipsAttachedTo(source)
	end
	if getElementType ( source ) == "vehicle" and dataName == "rent" then
		destroyBlipsAttachedTo(source)
	end
	if getElementType ( source ) == "vehicle" and dataName == "ownedGroup" then
		destroyBlipsAttachedTo(source)
	end
end )

addEvent("transfer:sound", true)
addEventHandler("transfer:sound", root, function()
local sound = playSound("transfer.mp3")
setSoundVolume(sound,0.6)
end)